﻿<UserControl x:Class="Parametrage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:OMANE.Modules.CRT"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
	<UserControl.Resources>
        <CollectionViewSource x:Key="ParametresView" Source="{Binding Parametres}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Groupe"/>
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
        
		<SolidColorBrush x:Key="{x:Static DataGrid.FocusBorderBrushKey}" Color="#FF000000"/>
        <ImageBrush x:Key="undoimg" ImageSource="../Ressources/Images/undo.png" />
		<ImageBrush x:Key="redoimg" ImageSource="../Ressources/Images/redo.png" />
		
		<Style TargetType="Button" x:Key="RedoButtonStyle">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Rectangle Name="rect" Fill="{DynamicResource redoimg}" />
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter  TargetName="rect" Property="Stroke" Value="Black" />
                                <Setter  TargetName="rect" Property="StrokeThickness" Value="3" />
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
		<Style TargetType="Button" x:Key="UndoButtonStyle">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Rectangle Name="rect" Fill="{DynamicResource undoimg}" />
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter  TargetName="rect" Property="Stroke" Value="Black" />
                                <Setter  TargetName="rect" Property="StrokeThickness" Value="3" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="Button" x:Key="UndoRedoButtonStyle">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border Name="brd"  CornerRadius="2">
                            <ContentPresenter Margin="2" ContentSource="Content" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter  TargetName="brd" Property="BorderBrush" Value="Black" />
                                <Setter  TargetName="brd" Property="BorderThickness" Value="2" />
                                <Setter  TargetName="brd" Property="Background" Value="Gray" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                            	<Setter Property="RenderTransform">
                            		<Setter.Value>
                            			<TransformGroup>
                            				<ScaleTransform ScaleX="0.8" ScaleY="0.8"/>
                            				<SkewTransform/>
                            				<RotateTransform/>
                            				<TranslateTransform/>
                            			</TransformGroup>
                            		</Setter.Value>
                            	</Setter>
                                                           
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
        </Style>
	</UserControl.Resources>
    <Grid>
        <DataGrid 
           ItemsSource="{Binding Source={StaticResource ParametresView}}"
           MinRowHeight="30"
            VerticalContentAlignment="Stretch" 
            HorizontalContentAlignment="Stretch" 
            HeadersVisibility="All"  Padding="0,10" 
            CanUserReorderColumns="False" 
            CanUserResizeColumns="True" 
            CanUserResizeRows="True"
            CanUserSortColumns="False" AutoGenerateColumns="False">
           
           

                <DataGrid.Columns>
                <DataGridTemplateColumn IsReadOnly="True"  Width="*">
        			<DataGridTemplateColumn.CellTemplate>
        				<DataTemplate>
        					<TextBlock  VerticalAlignment="Center" Text="{Binding Name}" TextAlignment="Right" Margin="0,0,10,0"  />				
						</DataTemplate>   			
					</DataGridTemplateColumn.CellTemplate>    		
				</DataGridTemplateColumn>
                <DataGridTemplateColumn  Width="*">
                    <DataGridTemplateColumn.CellEditingTemplateSelector>
                        <local:EditorSelector />
                    </DataGridTemplateColumn.CellEditingTemplateSelector>
                    <DataGridTemplateColumn.CellTemplateSelector>
                        <local:PresentorSelector />
                    </DataGridTemplateColumn.CellTemplateSelector>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn  Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <UniformGrid Columns="2">
                                <!--<Button Width="15" Height="15" Margin="1" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{DynamicResource UndoButtonStyle}" Command="{Binding UndoCommand}" />
                                <Button Width="15" Height="15" Margin="1" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{DynamicResource RedoButtonStyle}" Command="{Binding RedoCommand}"/>-->

                                <Button Content="Undo"  Margin="2"   HorizontalAlignment="Center" VerticalAlignment="Center" Style="{DynamicResource UndoRedoButtonStyle}" Command="{Binding UndoCommand}" />
                                	                              
                                <Button Content="Redo"  Margin="2"  HorizontalAlignment="Center" VerticalAlignment="Center" Style="{DynamicResource UndoRedoButtonStyle}" Command="{Binding RedoCommand}" />
                            </UniformGrid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        
            <DataGrid.GroupStyle>
                <x:Static Member="GroupStyle.Default"/>
            </DataGrid.GroupStyle>
        </DataGrid> 
    </Grid>
</UserControl>
